//
//  JUFNPictureShowView.swift
//  WiBoPM
//
//  Created by 陈俊峰 on 2017/1/10.
//  Copyright © 2017年 陈俊峰. All rights reserved.
//

import UIKit

class JUFNPictureShowView: UICollectionView {
   
    var pic_urls:[JUFNPicUrlsModel]?{
        didSet{
            self.reloadData()
        }
    }
    
    
    let picturesCellID = "picturesCellID"
    override func awakeFromNib() {
        //这里不需要调用父类
        register(JUFNPicturesCollectionCell.self, forCellWithReuseIdentifier: picturesCellID)
        //这里也要对Cell进行注册,并设置代理
        self.dataSource = self
        backgroundColor = randomColor
        
    }
}
//设置图片的排列方式

extension JUFNPictureShowView:UICollectionViewDataSource {
    //持有一个图片数据模型
    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
        
        return pic_urls?.count ?? 0
    }
    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
        
        let picCell = collectionView.dequeueReusableCell(withReuseIdentifier: picturesCellID, for: indexPath) as! JUFNPicturesCollectionCell
        picCell.pictureImgV.sd_setImage(with: pic_urls?[indexPath.row].picUrl)
        return picCell
    }

}
